{include file="public/header"}
<body>
<div class="layui-fluid" id="component-tabs">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div id="table" lay-filter="table"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="action">
    <a class="layui-btn  layui-btn-xs " lay-event="edit">编辑</a>
</script>
{include file="public/common"}
<script>
    var $;
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'element', 'upload','table'], function () {
        var $ = layui.$
            , form = layui.form
            , layer = layui.layer
            , table = layui.table
            , upload = layui.upload;

        table.render({
            elem: '#table'
            , url: '{:url("Template/templateList")}'
            , cols: [[
                {field: 'name', title: '名称',},
                {field: 'size', title: '大小', },
                {field: 'update_time', title: '修改时间',},
                {title: '操作', toolbar: '#action', align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            id: 'table_id',
            method: 'post'
        });

        table.on('tool(table)', function (obj) {
            var data = obj.data
                , layEvent = obj.event;
            if (layEvent == 'edit') {
                parent.layer.open({
                    type:2,
                    title: "编辑",
                    content: "{:url('Template/templateEdit')}?path=" + data.path,
                    area:["90%","90%"]
                });
            }
        });


        // 事件
        var active = {

            back: function () {
                parent.layer.closeAll();
            },

        };

        $('.layui-btn.ht-event').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        window.active = active;
    });
</script>
</body>
</html>
